* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: #333;
}

.container {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 20px;
  min-height: 100vh;
}

/* 页头样式 */
.header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.header-left {
  display: flex;
  gap: 12px;
  justify-content: flex-start;
}

.search-info {
  text-align: center;
}

.search-info h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 4px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.query-display {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
}

.query-text {
  background: #f8f9fa;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 500;
  color: #495057;
}

.header-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: #6c757d;
  color: white;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.action-btn.primary {
  background: linear-gradient(135deg, #007bff, #0056b3);
}

.action-btn.primary:hover {
  background: linear-gradient(135deg, #0056b3, #004494);
}

/* 搜索结果网格 */
.search-results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* 固定3列等宽 */
  gap: 20px;
  margin-bottom: 24px;
  transition: all 0.3s ease;
  width: 100%;
}

.search-results-grid.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  background: #f5f5f5;
  padding: 20px;
  margin: 0;
  grid-template-columns: repeat(3, 1fr); /* 全屏时也保持3列等宽 */
  gap: 20px;
  overflow-y: auto;
  width: 100%;
  max-width: none;
  justify-content: center;
}

.result-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.3s ease;
  border: 2px solid transparent;
  position: relative;
  min-height: 500px;
  display: flex;
  flex-direction: column;
}

.search-results-grid.fullscreen .result-card {
  min-height: calc(100vh - 80px);
  border-radius: 16px;
  margin: 0;
}

/* 全屏模式下的浮动退出提示 */
.fullscreen-exit-hint {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 2001;
  background: rgba(220, 53, 69, 0.95);
  color: white;
  padding: 12px 20px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px rgba(220, 53, 69, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.fullscreen-exit-hint:hover {
  background: rgba(220, 53, 69, 1);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(220, 53, 69, 0.6);
  border-color: rgba(255, 255, 255, 0.3);
}

.fullscreen-exit-hint:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(220, 53, 69, 0.4);
}

.result-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--engine-color, #007bff);
  z-index: 1;
}

.result-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  border-color: var(--engine-color, #007bff);
}

/* 搜索结果卡片内容 */
.result-header {
  padding: 12px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 2;
  flex-wrap: wrap;
  gap: 8px;
}

.result-engine-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.result-engine-icon {
  font-size: 1.3rem;
}

.result-engine-name {
  font-weight: 600;
  color: #495057;
  font-size: 0.95rem;
}

.result-meta-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: #6c757d;
  flex-wrap: wrap;
}

.result-count {
  font-size: 0.75rem;
  color: #6c757d;
  white-space: nowrap;
}

.result-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.result-iframe-container {
  flex: 1;
  position: relative;
  background: #f8f9fa;
}

.result-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

.result-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  z-index: 10;
}

.result-placeholder {
  text-align: center;
  color: #6c757d;
}

.result-placeholder-icon {
  font-size: 3rem;
  margin-bottom: 10px;
  opacity: 0.5;
}

.result-placeholder-text {
  font-size: 0.9rem;
  margin-bottom: 15px;
}

.load-result-btn {
  background: var(--engine-color, #007bff);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.load-result-btn:hover {
  filter: brightness(0.9);
  transform: scale(1.05);
}

.result-error {
  color: #dc3545;
  font-size: 0.9rem;
  text-align: center;
  padding: 20px;
}

.retry-btn {
  background: #dc3545;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  margin-top: 10px;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1rem;
  color: #6c757d;
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: #e9ecef;
  color: #495057;
}

.view-original-btn {
  padding: 4px 8px;
  background: #6c757d;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.view-original-btn:hover {
  background: #5a6268;
}

/* 新搜索模态窗口 */
.new-search-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.new-search-modal.show {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: white;
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.new-search-modal.show .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e9ecef;
}

.modal-header h3 {
  font-size: 1.3rem;
  font-weight: 600;
  color: #495057;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #6c757d;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.close-btn:hover {
  background: #f8f9fa;
  color: #495057;
}

.modal-body {
  padding: 24px;
}

.search-input {
  width: 100%;
  padding: 16px;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  font-size: 1.1rem;
  margin-bottom: 20px;
  transition: all 0.3s ease;
  outline: none;
  background: #fff;
}

.search-input:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
  transform: translateY(-1px);
}

.search-input::placeholder {
  color: #6c757d;
  transition: color 0.3s ease;
}

.search-input:focus::placeholder {
  color: #adb5bd;
}

.search-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* 模态框按钮统一样式 */
.search-actions .search-btn,
.modal-body .search-btn {
  background: #007bff;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.search-actions .search-btn:hover,
.modal-body .search-btn:hover {
  background: #0056b3;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.cancel-btn {
  background: #6c757d;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cancel-btn:hover {
  background: #5a6268;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(108, 117, 125, 0.3);
}

/* 当前搜索结果展示 */
.current-result {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: white;
  z-index: 800;
  display: none;
  flex-direction: column;
}

.current-result.show {
  display: flex;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
}

.result-header span {
  font-weight: 600;
  color: #495057;
}

.result-actions {
  display: flex;
  gap: 8px;
}

#resultFrame {
  flex: 1;
  width: 100%;
  border: none;
}

/* 超大屏幕优化 */
@media (min-width: 1800px) {
  .container {
    padding: 20px 40px; /* 大屏幕下增加左右内边距 */
  }

  .search-results-grid {
    grid-template-columns: repeat(3, 1fr); /* 保持3列等宽占满全屏 */
    gap: 24px; /* 稍微增大间距 */
  }

  .search-results-grid.fullscreen {
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
  }
}

/* 4K及超大屏幕优化 */
@media (min-width: 2560px) {
  .container {
    padding: 20px 80px; /* 4K屏幕下进一步增加内边距 */
  }

  .search-results-grid {
    gap: 30px; /* 更大的间距 */
  }

  .search-results-grid.fullscreen {
    gap: 30px;
  }
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .search-results-grid {
    grid-template-columns: repeat(2, 1fr); /* 中等屏幕显示2列 */
  }

  .search-results-grid.fullscreen {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .container {
    padding: 12px;
    width: 100%;
  }

  .header {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 12px;
    text-align: center;
    padding: 12px 16px;
  }

  .header-left {
    order: 2;
    justify-content: center;
  }

  .search-info {
    order: 1;
  }

  .header-actions {
    order: 3;
    justify-content: center;
  }

  .search-results-grid {
    grid-template-columns: 1fr; /* 小屏幕显示1列 */
    gap: 16px;
  }

  .search-results-grid.fullscreen {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .search-results-grid.fullscreen .result-card {
    min-height: calc(100vh - 100px);
  }

  .result-card {
    min-height: 400px;
  }

  .action-btn {
    padding: 10px 16px;
    font-size: 0.9rem;
  }

  .modal-content {
    margin: 20px;
  }

  .fullscreen-exit-hint {
    top: 15px;
    left: 15px;
    padding: 10px 16px;
    font-size: 13px;
  }
}

/* 深色主题 */
body.dark-theme {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

body.dark-theme .header,
body.dark-theme .engine-card {
  background: rgba(45, 45, 45, 0.95);
  color: #e0e0e0;
}

body.dark-theme .query-text {
  background: #3a3a3a;
  color: #e0e0e0;
}

body.dark-theme .engine-name {
  color: #e0e0e0;
}

body.dark-theme .feature-tag {
  background: #555;
  color: #e0e0e0;
}

body.dark-theme .modal-content {
  background: #2d2d2d;
  color: #e0e0e0;
}

body.dark-theme .search-input {
  background: #3a3a3a;
  border-color: #555;
  color: #e0e0e0;
}

body.dark-theme .search-input:focus {
  border-color: #0d7377;
}

/* 深色主题下的按钮样式 */
body.dark-theme .search-actions .search-btn,
body.dark-theme .modal-body .search-btn {
  background: #0d7377;
}

body.dark-theme .search-actions .search-btn:hover,
body.dark-theme .modal-body .search-btn:hover {
  background: #0a5c5f;
  box-shadow: 0 2px 8px rgba(13, 115, 119, 0.3);
}

body.dark-theme .cancel-btn {
  background: #495057;
}

body.dark-theme .cancel-btn:hover {
  background: #343a40;
  box-shadow: 0 2px 8px rgba(73, 80, 87, 0.3);
}

@media (prefers-color-scheme: dark) {
  body {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  }

  .header,
  .engine-card {
    background: rgba(45, 45, 45, 0.95);
    color: #e0e0e0;
  }

  .query-text {
    background: #3a3a3a;
    color: #e0e0e0;
  }

  .engine-name {
    color: #e0e0e0;
  }

  .feature-tag {
    background: #555;
    color: #e0e0e0;
  }

  .modal-content {
    background: #2d2d2d;
    color: #e0e0e0;
  }

  .search-input {
    background: #3a3a3a;
    border-color: #555;
    color: #e0e0e0;
  }

  .search-input:focus {
    border-color: #0d7377;
  }

  /* 深色主题下的按钮样式 */
  .search-actions .search-btn,
  .modal-body .search-btn {
    background: #0d7377;
  }

  .search-actions .search-btn:hover,
  .modal-body .search-btn:hover {
    background: #0a5c5f;
    box-shadow: 0 2px 8px rgba(13, 115, 119, 0.3);
  }

  .cancel-btn {
    background: #495057;
  }

  .cancel-btn:hover {
    background: #343a40;
    box-shadow: 0 2px 8px rgba(73, 80, 87, 0.3);
  }
}

/* 提取结果样式 */
.extracted-results {
  padding: 16px;
  height: 100%;
  overflow-y: auto;
  background: white;
}

/* 旧的results-header样式已移除，现在使用卡片header中的meta信息 */

.results-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 100%;
  overflow-y: auto;
  padding-right: 8px;
}

.extracted-result {
  padding: 12px;
  border-radius: 8px;
  background: #f8f9fa;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.extracted-result:hover {
  background: #e3f2fd;
  border-left-color: #1da1f2;
  transform: translateX(2px);
}

.result-title {
  margin-bottom: 6px;
}

.result-title a {
  color: #1da1f2;
  text-decoration: none;
  font-weight: 500;
  font-size: 16px;
  line-height: 1.3;
  display: block;
}

.result-title a:hover {
  text-decoration: underline;
}

.result-url {
  color: #22c55e;
  font-size: 13px;
  margin-bottom: 8px;
  word-break: break-all;
}

.result-snippet {
  color: #374151;
  font-size: 14px;
  line-height: 1.4;
}

/* 加载更多指示器 */
.load-more-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  color: #6c757d;
  font-size: 14px;
  border-top: 1px solid #e9ecef;
}

.loading-spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* 没有更多结果 */
.no-more-results {
  border-top: 1px solid #e9ecef;
  margin-top: 16px;
}

/* 滚动条样式 */
.results-list::-webkit-scrollbar {
  width: 6px;
}

.results-list::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.results-list::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.results-list::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* 暗色主题下的提取结果 */
body.dark-theme .extracted-results {
  background: #1e293b;
  color: #e2e8f0;
}

body.dark-theme .results-header {
  border-bottom-color: #374151;
}

body.dark-theme .results-count {
  color: #9ca3af;
}

body.dark-theme .extracted-result {
  background: #374151;
}

body.dark-theme .extracted-result:hover {
  background: #4b5563;
  border-left-color: #60a5fa;
}

@media (prefers-color-scheme: dark) {
  .extracted-results {
    background: #1e293b;
    color: #e2e8f0;
  }

  .results-header {
    border-bottom-color: #374151;
  }

  .results-count {
    color: #9ca3af;
  }

  .extracted-result {
    background: #374151;
  }

  .extracted-result:hover {
    background: #4b5563;
    border-left-color: #60a5fa;
  }

  .result-title a {
    color: #60a5fa;
  }

  .result-url {
    color: #34d399;
  }

  .result-snippet {
    color: #d1d5db;
  }

  .load-more-indicator {
    color: #9ca3af;
    border-top-color: #374151;
  }

  .no-more-results {
    border-top-color: #374151;
  }

  .results-list::-webkit-scrollbar-track {
    background: #374151;
  }

  .results-list::-webkit-scrollbar-thumb {
    background: #6b7280;
  }

  .results-list::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
  }
}
